define(['request','template','jquery'],(req,template) => {
    class Header{
        constructor(){
            this.init()
            this.getTabs()
        }
        init(){
            $('header').load('/html/modules/header.html',() => {
                this.allCount()
            })
            this.getTabs()
        }
        getTabs(){
            req.getIndexTab()
              .then(res =>{
                  if(res.code === 200){
                    const myData = res.data.list.slice(1,8)
                    $('.navleft').html(template('tabsTemplate',{list:myData}))
                }
              })
          }
        allCount(){
            let prodList = localStorage.getItem('prodList')
            let count = 0
            if(prodList){
                prodList =JSON.parse(prodList)
                prodList.forEach(item => {
                    count += item.isChecked ? item.count : 0
                })
            }
            $('#ShopCartNum').text(count)
        }
    }
    return new Header()
})